<?php

class PropertySetter  {
	
	const PROPERTY_ATTRIBUTE = 'attribute';
	const PROPERTY_ELEMENT = 'element';
	
	public static function setProperties ($object, $properties)  {

		if (!is_null($properties))  {
			foreach ($properties as $propertyKey => $property)  {

				if ($propertyKey == (self::PROPERTY_ATTRIBUTE || self::PROPERTY_ELEMENT))  {

					$baseFunction = 'set'. $propertyKey;
					foreach ($property as $elementKey => $element)  {

						$function = $baseFunction. $elementKey;
						if (is_callable(array($object, $function)))  {
							$object->$function($element);
						}
					
						empty($function);
					}
				}
			}
		}
		
	}
	
}